<?
include "banner.class.php";
?>
<html>
<body>
<?

/*---------*/
/* Example */
/*---------*/

$errors=0;
if ($_GET['act'] == "add") {
 // ??? ? ???????? ?????? submit
 if (isset($_POST['submit'])) {
  // ?????????? ?? ????????????
  $url = $_POST['url'];
  $image = $_POST['image'];
  $description = $_POST['description'];
  // ???????? ???? ???????? ?? ?????????
  if ($url == NULL || $image == NULL || $description == NULL) {
   echo "Fill all fields!";
   $errors++;
  }
  // ???????? ???? ?????????? ????? ?????
  else if ($banner->Exists($url, $image, $description)) {
   echo "Banner exists";
   $errors++;
  }
  // ??? ?????? ?????? ?? OK - ?????? ? ??
  else {
   if ($banner->addBanner($url, $image, $description)) {
    echo "Everything went fine :)";
    echo "<br /><a href='index.php'>Home</a>";
   }
   else {
    echo "An error encountered!";
    $errors++;
   }
  }
 }
 // ??? ?? ? ???????? ?????? "Submit"
 if (!isset($_POST['submit']) || $errors > 0) {
  echo '
  <form method="post" action="">
  URL: <input type="text" name="url" />
  Image URL: <input type="text" name="image" />
  Description: <input type="text" name="description" />
  <input type="submit" name="submit" />
  </form>
  <a href="index.php">Home</a>';
 }
}
else {

// ??????? ??????
$banner->showBanner();
echo "<br /><br /><a href='?act=add'>Add banner</a>";
}  
?>
</body>
</html>